import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../page/home/Home.vue'
import Login from '../page/login/Login.vue'
import WorkBench from '../modules/workbench/WorkBench.vue'
import Article from '../modules/article/Article.vue'
import CreateArticle from '../modules/createarticle/CreateArticle.vue'
import Message from '../modules/message/Message.vue'
import Comment from '../modules/comment/Comment.vue'
import Manager from '../modules/manager/Manager.vue'
import Information from '../modules/information/Information.vue'
import NotFound from '../page/notfound/NotFound.vue'

const routes = [
  {
    path: '/', component: Home,
    // 写法一
    redirect: "/home"
    // 写法二
    // redirect: (to => { return { path: '/shop' } })
  },
  {
    path: '/home', component: Home,
    children: [
      { path: "", component: WorkBench },
      { path: "workbench", component: WorkBench },
      { path: "createarticle", component: CreateArticle },
      { path: "article", component: Article },
      { path: "comment", component: Comment },
      { path: "message", component: Message },
      { path: "manager", component: Manager },
      { path: "information", component: Information },
    ],
  },
  { path: '/login', component: Login },
  {
    path: '/:pathMatch(.*)',
    // component: () => import('../views/notFound.vue')
    component: NotFound
  },
  // 方法二
  {
    path: '/:pathMatch(.*)*',
    // component: () => import('../views/notFound.vue')
    component: NotFound
  },
]

const router = createRouter({
  // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
  history: createWebHashHistory(),
  routes, // `routes: routes` 的缩写
})

export default router